package com.meida.module.bus.provider.handler;

import com.meida.common.base.entity.EntityMap;
import com.meida.common.base.utils.FlymeUtils;
import com.meida.common.mybatis.interceptor.GetInterceptor;
import com.meida.common.mybatis.query.CriteriaQuery;
import com.meida.module.admin.client.entity.BaseUser;
import com.meida.module.bus.client.enums.UserTypeEnum;
import com.meida.module.pay.client.entity.PayCashout;
import com.meida.module.user.client.entity.AppUser;
import org.springframework.stereotype.Component;

/**
 * 后台提现详情
 */
@Component
public class PayCashOutGetHandler implements GetInterceptor {


    @Override
    public void prepare(CriteriaQuery cq, EntityMap entityMap) {
        cq.clear();
        cq.select(PayCashout.class, "cashoutId", "userId", "userType", "shopId", "money", "commission", "ratio", "realMoney", "cashoutType", "aliPayAccount","checkState", "wxOpenId", "status", "reason", "createTime");
        cq.select(AppUser.class, "userName");
        cq.select("baseUser.userName operatorUserName");
        cq.createJoin(AppUser.class);
        cq.createJoin(BaseUser.class).setJoinAlias("baseUser").setMainField("operatorId").setJoinField("userId");
    }

    @Override
    public void complete(CriteriaQuery cq, EntityMap map) {
        String userType = map.get("userType");
        UserTypeEnum userTypeEnum = UserTypeEnum.getByValue(userType);
        map.put("userTypeText", "");
        if (FlymeUtils.isNotEmpty(userTypeEnum)) {
            map.put("userTypeText", userTypeEnum.getLabel());
        }
    }
}
